package com.chixing.service.impl;

import com.chixing.mapper.HotelInfoMapper;
import com.chixing.mapper.HotelRoomInfoMapper;
import com.chixing.pojo.HotelInfo;
import com.chixing.pojo.HotelInfoExample;
import com.chixing.pojo.HotelRoomInfo;
import com.chixing.pojo.HotelRoomInfoExample;
import com.chixing.service.HotelRoomTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;
@Service
public class HotelRoomTypeServiceImpl implements HotelRoomTypeService {
    @Autowired
    public HotelRoomInfoMapper hotelRoomInfoMapper;
    @Autowired
    public HotelInfoMapper hotelInfoMapper;
    @Override
    public List<HotelRoomInfo> getByName(String hotelName) {
        HotelInfoExample hotelInfoExample =  new HotelInfoExample();
        hotelInfoExample.createCriteria().andHotelNameEqualTo(hotelName);
        List<HotelInfo> hotelInfoList = hotelInfoMapper.selectByExample(hotelInfoExample);
        HotelRoomInfoExample hotelRoomInfoExample = new HotelRoomInfoExample();
        hotelRoomInfoExample.createCriteria().andHotelIdEqualTo(hotelInfoList.get(0).getHotelId());
        List<HotelRoomInfo> hotelRoomInfoList = hotelRoomInfoMapper.selectByExample(hotelRoomInfoExample);
        if(hotelRoomInfoList.size() > 0 ){
            return hotelRoomInfoList;
        }
        return null;
    }
}
